package online.longzipeng.mywebdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @Author: lzp
 * @description:
 * @Date: 2023/3/26
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

	/**
	 * 通用接口展示信息
	 *
	 * @return
	 */
	@Bean
	public ApiInfo appInfo() {
		return new ApiInfoBuilder()
				.title("springboot2.x的demo演示接口示例")
				.description("springboot2.x的接口示例")
				.termsOfServiceUrl("https://www.longzipeng.online/")
				.contact("lzp")
				.version("1.0")
				.build();
	}

	@Bean(value = "apiAll")
	public Docket defaultApi2(ApiInfo appInfo) {
		Docket docket = new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(appInfo)
				//分组名称
				.groupName("所有接口")
				.select()
				//这里指定Controller扫描包路径
//				.apis(RequestHandlerSelectors.basePackage("online.longzipeng.mywebdemo.controller"))
				.paths(PathSelectors.any())
				.build();
		return docket;
	}

}